//2, 导入BrowserRouter Route
import React, { Component } from 'react';
// as重命名 Router
// import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { Router, Route, Switch } from 'react-router-dom';

import Login from './pages/Login';
import MyLayout from './pages/Layout/index';
import TestPage from './pages/TestPage/index';
import { AuthRoute } from './components/AuthRoute';
import history from './utils/history';

export default class App extends Component {
  render() {
    return (
      //3,Router 包住所有的代码
      <Router history={history}>
        {/* 4,配置路由规则和组件,使用Switch包住所有的Router */}
        <Switch>
          {/* 5,设置重定向路由 */}
          <Route path="/login" component={Login}></Route>
          <Route path="/test" component={TestPage}></Route>
          <AuthRoute path="/" component={MyLayout}></AuthRoute>
        </Switch>
      </Router>
    );
  }
}
